<?php

    /* Login */
    if(isset($_POST['log']) && $_POST['log'] == "login") {
        $id = User::login($_POST['email'], md5($_POST['password']));
        if($id != false) {
            $_SESSION['user'] = new User($id);
            $_SESSION['user']->load();
            $_SESSION['user']->getFriends();

            if(isset($_POST['souvenir']) && $_POST['souvenir'] == "on")
                setcookie("ecitcookie",$_SESSION['user']['id'].'--'.$_SESSION['user']['hash'],time() + 52000);
        } else {
            header("Location:".URL_PATH."commande/panier/");
        }
    }

    /* Inscription */
    elseif(isset($_POST['log']) && $_POST['log'] == "sub") {
        require("subscription.form.php");
    }

?>